import { Decimal } from './decimal'

function reduceHandle (args = [], method = '') {
  return args.reduce(function (total, item) {
    return (new Decimal(total)[method](new Decimal(item))).toNumber()
  })
}

/**
 * 相加
 * @param  {...any} args 参数集
 */
export const ADD = (...args) => reduceHandle(args, 'add')

/**
 * 相减
 * @param  {...any} args 参数集
 */
export const SUB = (...args) => reduceHandle(args, 'sub')

/**
 * 相乘
 * @param  {...any} args 参数集
 */
export const MUL = (...args) => reduceHandle(args, 'mul')

/**
 * 相除
 * @param  {...any} args 参数集
 */
export const DIV = (...args) => reduceHandle(args, 'div')
